package com.tjetc.service.impl;

import com.tjetc.common.JsonResult;
import com.tjetc.common.vo.user.CommentParam;
import com.tjetc.dao.CityMapper;
import com.tjetc.dao.CommentMapper;
import com.tjetc.dao.UserMapper;
import com.tjetc.entity.City;
import com.tjetc.entity.Comment;
import com.tjetc.entity.User;
import com.tjetc.service.CityService;
import com.tjetc.service.CommentService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentServiceImpl implements CommentService {
    @Value("${token.expiration}")
    private int tokeExpiration;
    @Autowired
    private CommentMapper commentMapper;
    @Autowired
    private UserMapper userMapper;
    @Override
    public JsonResult addComment(CommentParam commentParam) {

      int n=commentMapper.insert(commentParam);
     if(n==0){return  JsonResult.fail("评论失败");}


        return JsonResult.success("评论成功");
    }

    @Override
    public JsonResult readComment(Long userId, Long status, Long bindId, Long upId) {
        List<Comment> comments=commentMapper.readComment(userId,status,bindId,upId);
        return JsonResult.success("获取评论成功",comments);
    }
}
